<template>
  <div>
    <ReviewType
      @e-courseType="handleClick"
      :flowRunTaskVOList="expertsTaskNumList"
      type="review"
    />
    <!-- 课程元素库审核 -->
    <UnReview :tableData="tableData" />
    <!-- 分页 -->
    <Pagination
      v-show="parseInt(pageObj.count) > 0"
      :total="parseInt(pageObj.count)"
      @change="getList"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
    />
    <!-- 评审弹窗 -->
    <ReviewDialog />
    <!-- 评审记录 -->
    <ReviewHistory />
  </div>
</template>
<script>
import { expertsTaskQuery } from '@/api/admin/audit/expertsTask.js'
import Bus from '@/utils/bus.js'
export default {
  components: {
    ReviewDialog: () => import('./ReviewDialog.vue'),
    ReviewType: () => import('../myAudit/ReviewType.vue'),
    UnReview: () => import('./UnReview.vue'),
    ReviewHistory: () => import('./ReviewHistory.vue'),
  },
  data() {
    return {
      activeName: '1',
      courseType: 1,
      listQuery: {
        page: 1,
        limit: 10,
        expertsId: this.$store.getters.userId,
        courseType: 1,
      },
      tableData: [],
      pageObj: {},
      expertsTaskNumList: [],
    }
  },
  mounted() {
    this.getList()
    Bus.$on('flowRunTaskList', (v) => {
      this.getList()
    })
  },
  beforeDestroy() {
    Bus.$off('flowRunTaskList')
  },
  methods: {
    getList() {
      expertsTaskQuery(this.listQuery).then((res) => {
        this.tableData = res.data.data[0].expertsTaskList
        this.pageObj = res.data
        this.expertsTaskNumList = res.data.data[0].expertsTaskNumList
      })
    },
    handleClick(v) {
      if (v) {
        this.courseType = v
        this.listQuery.courseType = v
        this.activeName = '1'
      }
      this.tableData = []
      this.pageObj = {}
      this.getList()
    },
  },
}
</script>